﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using Microsoft.Live.Core;
using Microsoft.Live.Messenger;
using Microsoft.Live.Messenger.UI;

namespace MessengerSample
{
    public partial class App : Application
    {
        private SignInControl signInControl;

        public App()
        {
            this.Startup += this.Application_Startup;

            InitializeComponent();
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
            this.RootVisual = new Page();

            this.signInControl = new SignInControl(
                "signInControl",
                "http://www.contoso.com/MessengerSample/privacy.html",
                "http://www.contoso.com/MessengerSample/channel.html");
            this.signInControl.AuthenticationCompleted += this.OnAuthenticationCompleted;
        }

        private void OnAuthenticationCompleted(object sender, AuthenticationCompletedEventArgs e)
        {
            ((Page)this.RootVisual).SetIdentity(e.Identity);
        }
    }
}
